<template>
  <div>
    <!-- <div class="center-s clearfix">
    <el-button type="primary" plain class="clickBack" @click="returnBack()">返回</el-button>
    </div> -->
    <div class="div-mau" style="padding:30px 60px;">
      <el-form :model="dataForm" :rules="dataRule" ref="dataForm" v-loading="dataListLoading" @keyup.enter.native="dataFormSubmit()" label-width="120px">
          <el-row>
              <el-col :span="12">
                  <el-form-item label="证书录入类型" prop="certificateType">
                    <el-select v-model="dataForm.certificateType" @change="changeCertificateType" style="width:100%">
                      <el-option
                        v-for="item in certificateTypes"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value"
                        >
                      </el-option>
                    </el-select>
                  </el-form-item>
              </el-col>
              <el-col :span="10">
                  <el-form-item label="保管人" prop="keepUserId">
                    <el-tree-select
                      style="width:50%"
                      :data="treeData"
                      v-model="dataForm.keepDeptId"
                      node-key="id"
                      placeholder="请选择保管人部门"
                      :clearable="true"
                      @change="keepDeptChange"
                      ref="casc"
                    />
                    <el-select v-model="dataForm.keepUserId" @change="employeesChange" filterable placeholder="请选择保管人" style="width:40%">
                      <el-option
                        v-for="item in employees"
                        :key="item.id"
                        :clearable="true"
                        :label="item.name"
                        :value="item.id">
                      </el-option>
                    </el-select>
                  </el-form-item>
              </el-col>
              <!-- 新增人员的按钮 s-->
              <el-col :span="2">
                <el-button @click="addOrUpdateHandleA()" type="primary" icon="el-icon-plus"> 新增</el-button>
              </el-col>
              <!-- 新增人员的按钮 e -->
          </el-row>
          <el-row>
              <el-col v-if="dataForm.certificateType == 1" :span="10" key="name1">
                <el-form-item label="持证人姓名" prop="id">
                  <el-select v-model="dataForm.id" filterable @change="changeName" placeholder="请选择持证人姓名" style="width:100%">
                      <el-option
                        v-for="item in dataEdit"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id">
                      </el-option>
                    </el-select>
                </el-form-item>
              </el-col>
              <el-col v-if="dataForm.certificateType == 1" :span="2">
                <el-button class="col-buttons" @click="addOrUpdateHandleB()" type="primary" icon="el-icon-plus"> 新增</el-button>
              </el-col>
              <el-col v-if="dataForm.certificateType == 2 || dataForm.certificateType == 3" :span="12" key="name2">
                <el-form-item label="持证人姓名" prop="name">
                  <el-input v-model="dataForm.name" placeholder="请填写持证人姓名"></el-input>
                </el-form-item>
              </el-col>
              <el-col v-if="dataForm.certificateType == 1" :span="12" key="id1">
                <el-form-item label="身份证号">
                  <el-input :readonly="this.readonly" v-model="dataForm.idCard" placeholder="请填写身份证号"></el-input>
                </el-form-item>
              </el-col>
              <el-col v-if="dataForm.certificateType == 2 || dataForm.certificateType == 3" :span="12" key="id2">
                <el-form-item label="身份证号" prop="idCard">
                  <el-input  v-model="dataForm.idCard" placeholder="请填写身份证号"></el-input>
                </el-form-item>
              </el-col>
          </el-row>
          <el-row>
              <el-col v-if="dataForm.certificateType == 1" :span="12" key="p1">
                <el-form-item label="手机号">
                  <el-input :readonly="this.readonly" v-model="dataForm.mobile" oninput="value=value.replace(/[^\d]/g,'')" maxlength="11" placeholder="请填写手机号"></el-input>
                </el-form-item>
              </el-col>
              <el-col v-if="dataForm.certificateType == 2 || dataForm.certificateType == 3" :span="12" key="p2">
                <el-form-item label="手机号" prop="mobile">
                  <el-input v-model="dataForm.mobile" oninput="value=value.replace(/[^\d]/g,'')" maxlength="11" placeholder="请填写手机号"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="学历" prop="academic">
                  <el-select v-model="dataForm.academic" placeholder="请选择学历" style="width:100%">
                      <el-option
                        v-for="item in academics"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                      </el-option>
                    </el-select>
                </el-form-item>
              </el-col>
          </el-row>
          <el-row>
              <el-col :span="12">
                <el-form-item label="证书类型" prop="idType">
                  <el-select v-model="dataForm.pIdType" filterable placeholder="请选择证书类型" style="width:50%" @change="jobChange">
                      <el-option
                        v-for="item in jobs"
                        :key="item.id"
                        :label="item.name"
                        :value="item.code">
                      </el-option>
                  </el-select>
                  <el-select v-model="dataForm.idType" filterable placeholder="请选择证书类别" style="width:49%" @change="confChange">
                    <el-option
                      v-for="item in confInfos"
                      :key="item.id"
                      :label="item.name"
                      :value="item.value">
                    </el-option>
                    </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="证书专业" prop="profession">
                  <el-select v-model="dataForm.profession" filterable placeholder="请选择证书专业" style="width:100%">
                      <el-option
                        v-for="item in professions"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                      </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
          </el-row>
          <el-row>
              <el-col :span="12">
                <el-form-item label="证书是否注册" prop="registerType">
                  <el-select v-model="dataForm.registerType" placeholder="请选择证书是否注册" style="width:100%">
                      <el-option
                        v-for="item in registerTypes"
                        :key="item.value"
                        :label="item.label"
                        :value="item.value">
                      </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="证书编号" prop="certificateNo">
                  <el-input v-model="dataForm.certificateNo" placeholder="请填写证书编号"></el-input>
                </el-form-item>
              </el-col>
          </el-row>
          <!-- 在职员工才会显示 -->
          <div v-if="dataForm.certificateType == 1 || dataForm.certificateType == 3">
          <el-row>
            <!-- <el-col :span="12">
             <el-form-item label="员工状态" prop="staff">
               <el-select v-model="dataForm.onCompanyFlag" placeholder="请选择" style="width:100%">
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
             </el-form-item>
            </el-col> -->
            <!-- <el-col :span="12" v-if="dataForm.onCompanyFlag == 0">
            <el-form-item label="离职日期" prop="companyEndTime">
              <el-date-picker type="date" v-model="dataForm.companyEndTime" placeholder="选择离职日期" style="width:100%"></el-date-picker>
            </el-form-item>
            </el-col> -->
            <el-col :span="12">
              <el-form-item label="考试地点">
                <el-input v-model="dataForm.examLocation" placeholder="请填写考试地点"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="考试分数">
                <el-input oninput="value=value.replace(/[^\d.]/g,'')" v-model="dataForm.examGrade" placeholder="请填写考试分数"></el-input>
              </el-form-item>
            </el-col>
            </el-row>
          </div>
          <el-row>
            <!-- 在职员工非在职员工的中介 -->
            <div v-if="dataForm.certificateType == 1 || dataForm.certificateType == 3">
            <el-col :span="12">
              <el-form-item label="考试通过猎头">
                <el-select v-model="dataForm.examAgencyFlag" placeholder="请选择" style="width:100%">
                <el-option
                  v-for="item in intermediary"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="dataForm.examAgencyFlag == 1" :span="12">
              <el-form-item label="猎头名称">
                <el-input v-model="dataForm.examAgencyName" placeholder="请填写中介名称"></el-input>
              </el-form-item>
            </el-col>
            <el-col v-if="dataForm.examAgencyFlag == 1" :span="12">
                  <el-form-item label="猎头费用">
                    <el-input oninput="value=value.replace(/^\.+|[^\d.]/g,'')" v-model="dataForm.examAgencyFee" placeholder="请填写中介费用"></el-input>
                  </el-form-item>
            </el-col>
            </div>
            <!-- 在职员工非在职员工的中介 -->

            <el-col v-if="dataForm.certificateType == 1 || dataForm.certificateType == 3" :span="12">
            <el-form-item label="考试日期">
              <el-date-picker type="date" v-model="dataForm.examTime" placeholder="选择考试日期" style="width:100%"></el-date-picker>
            </el-form-item>
            </el-col>
            <el-col :span="12" v-if="dataForm.certificateType == 1 || dataForm.certificateType == 3">
              <el-form-item label="考试总费用">
                <el-input oninput="value=value.replace(/[^\d.]/g,'')" v-model="dataForm.examFee" placeholder="请填写考试总费用"></el-input>
              </el-form-item>
            </el-col>
            <el-col v-if="dataForm.certificateType == 3" :span="12">
              <el-form-item label="非在职员工姓名" prop="friendshipEmployeeId">
                <!-- <el-input v-model="dataForm.borrowContact" placeholder="请填写非在职员工姓名"></el-input> -->
                <el-select v-model="dataForm.friendshipEmployeeId" @change="changeFriendshipEmployeeId" placeholder="请选择非在职员工姓名" style="width:100%">
                      <el-option
                        v-for="item in dataEdit"
                        :key="item.value"
                        :label="item.name"
                        :value="item.id">
                      </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <div v-if="dataForm.certificateType == 3">
          <el-row>
            <el-col :span="12">
              <el-form-item label="非在职员工关系">
                <el-input v-model="dataForm.borrowContactRelationship" placeholder="请填写非在职员工关系"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item v-if="dataForm.certificateType == 3" label="非在职员工联系方式">
                <el-input :readonly="this.readonlyEdit" v-model="dataForm.friendshipMobile" placeholder="请填写非在职员工联系方式"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          </div>
          <!-- 在职员工结束 -->
          <el-row>
              <el-col :span="12">
                <el-form-item label="发证日期">
                  <el-date-picker type="date" v-model="dataForm.releaseTime" placeholder="选择发证日期" :picker-options="pickerOptionsBeginValidityEndTime" style="width:100%"></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="证书到期日期">
                  <el-date-picker type="date" v-if="!checked" v-model="dataForm.validityEndTime" format="yyyy-MM-dd" placeholder="选择证书到期日期" style="width:78%" @blur="blurValidityEndTime" :picker-options="pickerOptionsValidityEndTime"></el-date-picker>
                  <el-checkbox style="width:20%; height:100%;" v-model="checked" label="长期有效" border size="medium"></el-checkbox>
                </el-form-item>
              </el-col>
          </el-row>
          <div v-if="dataForm.certificateType == 2">
            <el-row>
                <el-col :span="12">
                  <el-form-item label="挂靠日期">
                    <el-date-picker type="date" v-model="dataForm.borrowTime" :picker-options="pickerOptionsBorrowEndTimeAe" placeholder="选择挂靠日期" style="width:100%"></el-date-picker>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="结束日期">
                    <el-date-picker type="date" v-model="dataForm.borrowEndTime" placeholder="选择结束日期" style="width:100%" @blur="blurBorrowEndTime" :picker-options="pickerOptionsBorrowEndTime"></el-date-picker>
                  </el-form-item>
                </el-col>
            </el-row>
          <el-row v-if="dataForm.certificateType == 2">
                <el-col :span="12">
                  <el-form-item label="拿进人">
                    <el-select v-model="dataForm.affiliationEmployee" placeholder="请选择拿进人" style="width:100%">
                      <el-option
                        v-for="item in dataEdit"
                        :key="item.value"
                        :label="item.name"
                        :value="item.id">
                      </el-option>
                </el-select>
                  </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                  <el-form-item label="来源企业">
                    <el-input v-model="dataForm.borrowOrgName" placeholder="请填写来源企业名称"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="来源联系人">
                    <el-input v-model="dataForm.borrowContact" maxlength="11" placeholder="请填写来源联系人"></el-input>
                  </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                  <el-form-item label="来源联系方式" prop="borrowContactMobile">
                    <el-input v-model="dataForm.borrowContactMobile" oninput="value=value.replace(/[^\d]/g,'')" placeholder="请填写来源联系方式"></el-input>
                  </el-form-item>
                </el-col>
                <!-- 挂靠的中介 -->
            <el-col :span="12">
              <el-form-item label="挂靠通过猎头">
                <el-select v-model="dataForm.agencyFlag" placeholder="请选择" style="width:100%">
                <el-option
                  v-for="item in intermediary"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
              </el-form-item>
            </el-col>
            <el-col v-if="dataForm.agencyFlag == 1" :span="12">
              <el-form-item label="猎头名称">
                <el-input v-model="dataForm.agencyName" placeholder="请填写猎头名称"></el-input>
              </el-form-item>
            </el-col>
            <el-col v-if="dataForm.agencyFlag == 1" :span="12">
                  <el-form-item label="猎头费用">
                    <el-input oninput="value=value.replace(/^\.+|[^\d.]/g,'')" v-model="dataForm.agencyFee" placeholder="请填写猎头费用"></el-input>
                  </el-form-item>
            </el-col>
                <el-col :span="12">
                  <el-form-item label="人才费用" prop="affiliationExpend">
                    <el-input  v-model="dataForm.affiliationExpend" @input="changeaffiliationIncome(dataForm.affiliationExpend)" placeholder="请填写人才费用"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="引进总价">
                    <el-input oninput="value=value.replace(/^\.+|[^\d.]/g,'')" :readonly="true" v-model="dataForm.totalFee" placeholder="猎头费用+人才费用"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="是否已支付">
                   <el-select v-model="dataForm.payFlag" placeholder="请选择" style="width:100%">
                    <el-option
                      v-for="item in optionsPayment"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="是否税后">
                    <el-select v-model="dataForm.tax" placeholder="请选择" style="width:100%">
                    <el-option
                      v-for="item in optionsAT"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value">
                    </el-option>
                  </el-select>
                  </el-form-item>
                </el-col>
            <!-- <el-row>
                <el-col :span="24">
                  <el-form-item label="上传兼职合同">
                    <el-select v-model="dataForm.uploadType" placeholder="请选择是否上传兼职合同" style="width:100%">
                        <el-option
                          v-for="item in uploadTypes"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value">
                        </el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
            </el-row> -->
              <el-col :span="12">
                  <el-form-item label="支付日期">
                    <el-date-picker type="date" v-model="dataForm.payTime" placeholder="选择支付日期" style="width:100%"></el-date-picker>
                  </el-form-item>
                </el-col>
            </el-row>
          </div>
          <el-row>
            <el-col v-if="dataForm.certificateType == 1 || dataForm.certificateType == 3" :span="12">
              <el-form-item label="费用说明">
                <el-input type="textarea" :rows="6" v-model="dataForm.feeRemark" placeholder="请填写考试、中介、住宿、来回车费等费用说明"></el-input>
              </el-form-item>
            </el-col>
            <el-col v-if="dataForm.certificateType == 2" :span="12">
              <el-form-item label="费用说明">
                <el-input type="textarea" :rows="6" v-model="dataForm.feeRemark" placeholder="请填写中介费、等费用说明"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="情况说明">
                <el-input type="textarea" :rows="6" v-model="dataForm.remark" placeholder="请填写情况说明"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="上传证书扫描件">
                <el-upload
                 class="upload-ss"
                 :action="uploadUrl()"
                  accept =".jpg,.png"
                  :headers="myHeader"
                  :limit="limitNum"
                  :show-file-list="showList"
                  :on-success="onCertiSuccess"
                  :file-list="img"
                  :on-error="onError"
                  ref="certiUpload"
                  list-type="picture-card"
                 >
                 <i slot="default" class="el-icon-plus"></i>
                 <div @click="clickFilets(file)" class="div-ssup" slot="file" slot-scope="{file}">
                <img
                  class="el-upload-list__item-thumbnail"
                  :src="file.url" alt=""
                >
                <span class="el-upload-list__item-actions">
                 <span
                 class="el-upload-list__item-preview"
                 @click="imgHandlePictureCardPreview(file)"
                >
                <i class="el-icon-zoom-in"></i>
               </span>
               <span
                 v-if="!disabled"
                 class="el-upload-list__item-delete delete-sse"
                 @click.stop="imgHandleRemove(file)"
               >
                 <i class="el-icon-delete"></i>
               </span>
              </span>
             </div>
             </el-upload>
             <el-dialog :visible.sync="imageDialogVisible">
             <img width="100%" :src="imgDialogImageUrl" alt="">
             </el-dialog>
             <!-- 上传图片 -->
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item v-if="dataForm.certificateType == 2" label="上传打款凭证">
                <el-upload
                  ref="contractUpload"
                  accept =".jpg,.png"
                  :action="uploadUrl()"
                  :with-credentials="true"
                  :on-remove="onRemove"
                  :headers="myHeader"
                  :limit="limitNum"
                  :show-file-list="showList"
                  :on-success="onContractSuccess"
                  :on-error="onError"
                  list-type="picture-card">
                  <i class="el-icon-plus"></i>
                  <!-- <div class="el-upload__tip" slot="tip">只能上传jpg/png图片文件，且不超过800kb，其他无效</div> -->
                </el-upload>
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item style="text-align:center;padding-right:120px;">
            <el-button class="button-see" size="mini" plain @click="gotoRouteHandle()">返 回</el-button>
            <el-button class="button-see" size="mini" type="primary" @click="dataFormSubmit()">保 存</el-button>
          </el-form-item>
      </el-form>
      <el-dialog
      title="错误提示"
      :visible.sync="dataFormSubmitCenterDialogVisible"
      width="30%"
      center>
      <span class="cuowu">上述必填信息有误，请填写完整！</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dataFormSubmitCenterDialogVisible = false">关 闭</el-button>
      </span>
      </el-dialog>
    </div>
    <!-- 新增人员组件 -->
    <!-- <certificate-update v-if="addOrUpdateVisible" ref="addOrUpdate"></certificate-update> -->
    <add-or-update :manualupdate="manualupdate" v-if="addOrUpdateVisible" ref="addOrUpdate"></add-or-update>
  </div>
</template>

<script>
  import Vue from 'vue'
  import ElTreeSelect from '@/components/treeSelect/index.vue'
  // import merge from 'lodash/merge'
  import AddOrUpdate from '@/views/modules/company/em/employee-add-or-update.vue'

const chinaIdentityValid = (rule, value, callback) => {
    if (!value) {
      return callback()
    }
    let city = {
      11: '北京',
      12: '天津',
      13: '河北',
      14: '山西',
      15: '内蒙古',
      21: '辽宁',
      22: '吉林',
      23: '黑龙江 ',
      31: '上海',
      32: '江苏',
      33: '浙江',
      34: '安徽',
      35: '福建',
      36: '江西',
      37: '山东',
      41: '河南',
      42: '湖北 ',
      43: '湖南',
      44: '广东',
      45: '广西',
      46: '海南',
      50: '重庆',
      51: '四川',
      52: '贵州',
      53: '云南',
      54: '西藏 ',
      61: '陕西',
      62: '甘肃',
      63: '青海',
      64: '宁夏',
      65: '新疆',
      71: '台湾',
      81: '香港',
      82: '澳门',
      91: '国外'
    }
    if (!value || !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(value)) {
      callback(new Error('身份证号格式错误'))
    } else if (!city[value.substr(0, 2)]) {
      callback(new Error('身份证号格式错误'))
    } else {
      // 18位身份证需要验证最后一位校验位
      if (value.length === 18) {
        const code = value.split('')
        // ∑(ai×Wi)(mod 11)
        // 加权因子
        const factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
        // 校验位
        const parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2]
        let sum = 0
        let ai = 0
        let wi = 0
        for (let i = 0; i < 17; i++) {
          ai = code[i]
          wi = factor[i]
          sum += ai * wi
        }
        if (parity[sum % 11].toString() !== code[17]) {
          callback(new Error('输入的身份证号有误'))
        }
      }
    }
    callback()
  }

   // 验证手机号的规则;
  var checkMobile = (rule, value, cb) => {
      // 验证手机号的正则表达式
    // const regMobile = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/
    const regMobile = /^1[0-9]{10}$/
    if (regMobile.test(value) || !value) {
      return cb()
    }
    cb(new Error('请输入合法的手机号'))
  }

export default {
    name: 'CertificateManual',
    data () {
      return {
        manualupdate: 0,
        dataFormSubmitCenterDialogVisible: false,
        imageDialogVisible: false,
        imgDialogImageUrl: '',
        disabled: false,
        readonly: false,
        readonlyEdit: false,
        visible: false,
        checked: false,
        dataEdit: [],
        addOrUpdateVisible: false,
        certificateTypes: [{
          value: 1,
          label: '在职员工'
        }, {
          value: 2,
          label: '挂靠'
        }, {
          value: 3,
          label: '非在职员工'
        }
        ],
        options: [{
          value: 1,
          label: '在职'}, {
            value: 0,
            label: '离职'
          }
        ],
        intermediary: [
          {
            value: 1,
            label: '是'
          },
          {
            value: 0,
            label: '否'
          }
        ],
        academics: [{
          value: '博士',
          label: '博士'
        }, {
          value: '硕士',
          label: '硕士'
        }, {
          value: '本科',
          label: '本科'
        }, {
          value: '专科',
          label: '专科'
        }, {
          value: '高职高专',
          label: '高职高专'
        }, {
          value: '中专',
          label: '中专'
        }, {
          value: '高中',
          label: '高中'
        }, {
          value: '初中',
          label: '初中'
        }, {
          value: '小学',
          label: '小学'
        }, {
          value: '其他',
          label: '其他'
        }],
        registerTypes: [{
          value: 0,
          label: '否'
        }, {
          value: 1,
          label: '是'
        }, {
          value: 2,
          label: '非注册类证书'
        }],
        candidatesSources: [{
          value: 1,
          label: '个人'
        }, {
          value: 2,
          label: '企业'
        }],
        uploadTypes: [{
          value: 0,
          label: '是'
        }, {
          value: 1,
          label: '否'
        }],
        dataForm: {
          id: '',
          payTime: '',
          agencyFee: null,
          remark: '',
          feeRemark: '',
          payFlag: 1,
          tax: 0,
          longTerm: 0,
          employeeId: '',
          examAgencyFlag: '',
          examAgencyName: '',
          examAgencyFee: '',
          affiliationEmployee: '',
          affiliationExpend: null,
          agencyName: '',
          agencyFlag: '',
          borrowContact: '',
          friendshipEmployeeId: '',
          borrowContactRelationship: '',
          examFee: '',
          examGrade: '',
          examLocation: '',
          examTime: '',
          onCompanyFlag: 1,
          certificateType: 1,
          uploadType: 0,
          keepDeptId: '',
          keepUserId: '',
          name: '',
          pIdType: '',
          idType: '',
          idCard: '',
          certificateNo: '',
          mobile: '',
          profession: '',
          academic: '',
          registerType: '',
          releaseTime: '',
          validityEndTime: '',
          // remark: '',
          orgName: '',
          contact: '',
          contactMobile: '',
          borrowCandidatesSources: '',
          borrowOrgName: '',
          // borrowContact: '',
          borrowContactMobile: '',
          friendshipMobile: '',
          borrowTime: '',
          borrowEndTime: '',
          companyEndTime: '',
          totalFee: ''
        },
        optionsPayment: [{
          value: 1,
          label: '是'
        }, {
          value: 0,
          label: '否'
        }],
        payment: '',
        optionsAT: [{
          value: 1,
          label: '是'
        }, {
          value: 0,
          label: '否'
        }],
        valueAT: '',
        pickerOptionsValidityEndTime: {
          disabledDate: (time) => {
            return time.getTime() < this.dataForm.releaseTime
          }
        },
        pickerOptionsBeginValidityEndTime: {},
        pickerOptionsBorrowEndTime: {
          disabledDate: (time) => {
            return time.getTime() < this.dataForm.borrowTime
          }
        },
        pickerOptionsBorrowEndTimeAe: {},
        dataRule: {
          certificateType: [
            { required: true, message: '请选择证书录入类型', trigger: 'blur' }
          ],
          id: [
            { required: true, message: '请填写持证人姓名', trigger: 'blur' }
          ],
          name: [
            { required: true, message: '请填写持证人姓名', trigger: 'blur' }
          ],
          friendshipEmployeeId: [
            { required: true, message: '请选择非在职员工姓名', trigger: 'blur' }
          ],
          idType: [
            { required: true, message: '请选择证书类型', trigger: 'blur' }
          ],
          certificateNo: [
            { required: true, message: '请填写证书编号', trigger: 'blur' }
          ],
          idCard:
          [
             { required: true, message: '请填写身份证号', trigger: 'blur' },
             { validator: chinaIdentityValid, trigger: 'blur'}
          ],
          mobile: [
            // { required: true, message: '请填写手机号', trigger: 'blur' },
            { len: 11, validator: checkMobile, message: '请填写正确的手机号', trigger: 'blur'}
          ],
          borrowContactMobile: [
            { message: '请填写正确的手机号', len: 11, trigger: 'blur'}
          ],
          releaseTime: [
            { required: true, message: '请选择发证日期', trigger: 'blur' }
          ],
          companyEndTime: [
            { required: true, message: '请选择离职日期', trigger: 'blur' }
          ],
          validityEndTime: [
            { required: true, message: '请选择证书到期日期', trigger: 'blur' }
          ],
          keepDeptId: [
            { required: true, message: '请选择保管单位', trigger: 'blur' }
          ],
          keepUserId: [
            { required: true, message: '请选择保管人', trigger: 'blur' }
          ],
          profession: [
            { required: true, message: '请选择证书专业', trigger: 'blur' }
          ],
          remark: [
            { required: true, message: '请选择备注信息不能为空', trigger: 'blur' }
          ],
          borrowTime: [
            { required: true, message: '请选择借入时间', trigger: 'blur' }
          ],
          borrowEndTime: [
            { required: true, message: '请选择到期日期', trigger: 'blur' }
          ],
          orgName: [
            { required: true, message: '请填写来源企业名称', trigger: 'blur' }
          ],
          contact: [
            { required: true, message: '请填写联系人', trigger: 'blur' }
          ],
          affiliationExpend: [
            { required: true, message: '请填写人才费用', trigger: 'blur' }
          ],
          contactMobile: [
            { required: true, len: 11, message: '请填写联系人手机号', trigger: 'blur' }
          ]
        },
        treeData: [],
        certiPicList: [],
        constractPicList: [],
        dataListLoading: false,
        payPic: [],
        jobs: [],
        dataListName: {},
        limitNum: 1, // 上传excell时，同时允许上传的最大数
        jobName: '',
        confInfos: [],
        professions: [],
        employees: [],
        dialogImageUrl: '',
        dialogVisible: false,
        disabled: false,
        showList: true,
        area: {11: '北京',
          12: '天津',
          13: '河北',
          14: '山西',
          15: '内蒙古',
          21: '辽宁',
          22: '吉林',
          23: '黑龙江',
          31: '上海',
          32: '江苏',
          33: '浙江',
          34: '安徽',
          35: '福建',
          36: '江西',
          37: '山东',
          41: '河南',
          42: '湖北',
          43: '湖南',
          44: '广东',
          45: '广西',
          46: '海南',
          50: '重庆',
          51: '四川',
          52: '贵州',
          53: '云南',
          54: '西藏',
          61: '陕西',
          62: '甘肃',
          63: '青海',
          64: '宁夏',
          65: '新疆',
          71: '台湾',
          81: '香港',
          82: '澳门',
          91: '国外'
        }
      }
    },
    props: {
      dateFrom: {
        type: Object
            // required: true
      },
      img: {
        type: Array
      },
      isField: {
        type: Boolean
            // required: true
      },
      dataListForm: {
        type: Object
      },
      editmodification: {
        type: Boolean
      }
    },
    components: {
      ElTreeSelect,
      // CertificateUpdate
      AddOrUpdate
    },
    watch: {
// this.dataForm.agencyFee + this.dataForm.affiliationExpend
      'dataForm.agencyFee': {
        handler: function (a, b) {
          this.dataForm.totalFee = (a - 0) + (this.dataForm.affiliationExpend - 0)
        }
      },
      'dataForm.affiliationExpend': {
        handler: function (a, b) {
          this.dataForm.totalFee = (a - 0) + (this.dataForm.agencyFee - 0)
        }
      }
      // dataForm.affiliationExpend:{
      // handler(){},
      // }
    },
    computed: {
      myHeader () {
        return {
          'token': Vue.cookie.get('token')
        }
      }
    },
    created () {
      // console.log(this.img);
      this.dataKive()
      this.keepDeptDataEdit()
      this.initOrgTree()
      this.initJobs()
      this.dataListForms()
      this.keepDeptChange()
      this.jobChange()
      this.confChange()
      // this.changeName()
    },
    methods: {
      blurValidityEndTime () {
        if (this.dataForm.validityEndTime !== '') {
          this.pickerOptionsBeginValidityEndTime = {
            disabledDate: (time) => {
              return time.getTime() > this.dataForm.validityEndTime
            }
          }
        } else {
          this.pickerOptionsBeginValidityEndTime = {}
        }
      },
      blurBorrowEndTime () {
        if (this.dataForm.borrowEndTime !== '') {
          this.pickerOptionsBorrowEndTimeAe = {
            disabledDate: (time) => {
              return time.getTime() > this.dataForm.borrowEndTime
            }
          }
        } else {
          this.pickerOptionsBorrowEndTimeAe = {}
        }
      },
      changeaffiliationIncome (val) {
        val = val.replace(/(^\s*)|(\s*$)/g, '')
        if (!val) {
          this.a = ''
          return
        }
        var reg = /[^\d.]/g

                // 只能是数字和小数点，不能是其他输入
        val = val.replace(reg, '')

                // 保证第一位只能是数字，不能是点
        val = val.replace(/^\./g, '')
              // 小数只能出现1位
        val = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.')
              // 小数点后面保留2位
        val = val.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3')
        this.dataForm.affiliationExpend = val
  },
      clickEfocus () {
      // this.pickerOptionsValidityEndTime.disabledDate(this.dataForm.)
      },
      /**
   * 中国身份证详细验证
   */
  chinaIdentityValid: (rule, value, callback) => {
    if (!value) {
      return callback()
    }
    let city = {
      11: '北京',
      12: '天津',
      13: '河北',
      14: '山西',
      15: '内蒙古',
      21: '辽宁',
      22: '吉林',
      23: '黑龙江 ',
      31: '上海',
      32: '江苏',
      33: '浙江',
      34: '安徽',
      35: '福建',
      36: '江西',
      37: '山东',
      41: '河南',
      42: '湖北 ',
      43: '湖南',
      44: '广东',
      45: '广西',
      46: '海南',
      50: '重庆',
      51: '四川',
      52: '贵州',
      53: '云南',
      54: '西藏 ',
      61: '陕西',
      62: '甘肃',
      63: '青海',
      64: '宁夏',
      65: '新疆',
      71: '台湾',
      81: '香港',
      82: '澳门',
      91: '国外'
    }
    if (!value || !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(value)) {
      callback(new Error('身份证号格式错误'))
    } else if (!city[value.substr(0, 2)]) {
      callback(new Error('身份证号格式错误'))
    } else {
      // 18位身份证需要验证最后一位校验位
      if (value.length === 18) {
        const code = value.split('')
        // ∑(ai×Wi)(mod 11)
        // 加权因子
        const factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
        // 校验位
        const parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2]
        let sum = 0
        let ai = 0
        let wi = 0
        for (let i = 0; i < 17; i++) {
          ai = code[i]
          wi = factor[i]
          sum += ai * wi
        }
        if (parity[sum % 11].toString() !== code[17]) {
          callback(new Error('输入的身份证号有误'))
        }
      }
    }
    callback()
  },
      imgHandleRemove (file) {
        this.$refs.certiUpload.clearFiles()
      },
      imgHandlePictureCardPreview (file) {
        this.imgDialogImageUrl = file.url
        this.imageDialogVisible = true
      },
      // clickfocsus(){
      // this.pickerOptionsValidityEndTime.disabledDate(this.dataForm.validityEndTime) =
      // },
      // 返回上一层
      returnBack () {
        this.$emit('routerBack')
        this.$refs.dataForm.resetFields()
      },
      // 智能导入 同步数据
      dataKive () {
        this.dataForm = {...this.dataForm, ...this.dateFrom}
        // console.log("dataForm", this.dataForm)
        if (this.dataForm.employeeId) {
          this.dataForm.id = this.dataForm.employeeId
        }
        // if(this.dataEdit.length !== 0){
        // this.dataEdit.forEach(i => {
        // })
        // }
      // }
      },
      dataListForms () {
        this.dataForm = {...this.dataForm, ...this.dataListForm}
        if (this.dataListForm) {
          this.dataForm.id = this.dataListForm.employeeId
          this.dataForm.releaseTime = new Date(this.dataListForm.releaseTime)
          this.dataForm.borrowTime = new Date(this.dataListForm.borrowTime)
          if (this.dataForm.certificateType == 1) {
            this.readonly = true
          }
          if (this.dataForm.certificateType == 3) {
            this.readonlyEdit = true
          }
        }
      },
      // 新增人员
      addOrUpdateHandleA (id) {
        this.addOrUpdateVisible = true
        this.manualupdate = 1
        this.$nextTick(() => {
          this.$refs.addOrUpdate.init(id)
        })
      },
      addOrUpdateHandleB (id) {
        this.manualupdate = 2
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.addOrUpdate.init(id)
        })
      },
      handleRemove (file) {
      },
      handlePictureCardPreview (file) {
        this.dialogImageUrl = file.url
        this.dialogVisible = true
      },
      handleDownload (file) {
      },
      init (tenantId) {
        this.tenantId = tenantId
      },
      onRemove (file, fileList) {
      },
      onCertiSuccess (response, file, fileList) {
        this.imgDialogImageUrl = response.remoteUrl + response.fileName
        this.certiPicList = fileList
      },
      clickFilets (file) {
        this.imgHandlePictureCardPreview(file)
      },
      onContractSuccess (response, file, fileList) {
        this.payPic = fileList
      },
      onError (err, file, fileList) {
        this.$message.error('上传失败')
      },
      uploadUrl () {
        return this.$http.adornUrl(`/certificate/certificateInfo/upload`)
      },
      initJobs () {
        this.$http({
          url: this.$http.adornUrl('/certificate/certificateInfo/getJobs'),
          method: 'get',
          params: {}
        }).then(({data}) => {
          if (data && data.length > 0) {
            this.jobs = data
          }
        })
      },
      changeCertificateType (value) {
      // console.log(123);
      // console.log(value);
        if (value === 3 || 2) {
          this.readonly = false
        }
        if (this.dataForm.certificateType === 3) {
          this.readonlyEdit = true
        }
      },
      jobChange (value) {
        if (!this.dataListForm) {
          this.confInfos = []
          this.professions = []
      // this.dataForm.idType = ''
      // this.dataForm.profession = ''
          this.$http({
            url: this.$http.adornUrl('/certificate/certificateInfo/getJobsConf'),
            method: 'get',
            params: this.$http.adornParams({
              'type': this.dataForm.pIdType
            })
          }).then(({data}) => {
            if (data && data.length > 0) {
              this.confInfos = data
            }
          })
        } else {
          this.confInfos = []
          this.professions = []
          value = this.dataForm.pIdType
          this.$http({
            url: this.$http.adornUrl('/certificate/certificateInfo/getJobsConf'),
            method: 'get',
            params: this.$http.adornParams({
              'type': value
            })
          }).then(({data}) => {
            if (data && data.length > 0) {
              this.confInfos = data
            }
          })
        }
      },
      confChange (value) {
        if (!this.dataListForm) {
          this.professions = []
        // this.dataForm.profession = ''
          if (this.dateFrom.idType) {
            value = this.dateFrom.idType
          }
          this.$http({
            url: this.$http.adornUrl('/certificate/certificateInfo/getJobsConf'),
            method: 'get',
            params: this.$http.adornParams({
              'type': value
            })
          }).then(({data}) => {
            if (data && data.length > 0) {
              this.professions = data
            }
          })
        } else {
          value = this.dataForm.idType
          this.professions = []
          this.$http({
            url: this.$http.adornUrl('/certificate/certificateInfo/getJobsConf'),
            method: 'get',
            params: this.$http.adornParams({
              'type': value
            })
          }).then(({data}) => {
            if (data && data.length > 0) {
              this.professions = data
            }
          })
        }
      },
      gotoRouteHandle () {
        this.$emit('isDateEdit')
        this.$emit('getAddUser')
        this.$emit('routerBack')
        this.$emit('initJobs')
        this.$refs.dataForm.resetFields()
      },
      keepDeptDataEdit () {
        this.$http({
          url: this.$http.adornUrl('/certificate/employeeInfo/getEmployeeInfos'),
          // url: this.$http.adornUrl('/certificate/employeeInfo/holders'),
          method: 'get',
          params: this.$http.adornParams({
            'deptId': 0
          })
        }).then(({data}) => {
          if (data.length > 0) {
            this.dataEdit = data
           // this.dataForm.id = this.dataEdit[0].id
//            this.dataForm.employeeId = this.dataEdit[0].id
            if (this.dateFrom.idCard !== '') {
              this.dataEdit.forEach(i => {
                if (i.idCard === this.dateFrom.idCard) {
            // this.dataForm.id = i.id
                }
              })
            }
          // console.log(data);
          }
        })
      },
      changeName (id) {
        this.dataForm.employeeId = id
        this.$http({
          url: this.$http.adornUrl('/certificate/employeeInfo/info/' + id),
          method: 'get'
        }).then(({data}) => {
        // this.dataListName = data.e
        // this.dataForm.name = data.e.name
          if (this.dataForm.certificateType === 1) {
            this.dataForm.idCard = data.e.idCard
            this.dataForm.mobile = data.e.mobile
            this.dataForm.academic = data.e.academic
            this.readonly = true
          }
        })
      },
      changeFriendshipEmployeeId (id) {
        this.$http({
          url: this.$http.adornUrl('/certificate/employeeInfo/info/' + id),
          method: 'get'
        }).then(({data}) => {
      // this.dataListName = data.e
          this.dataForm.friendshipMobile = data.e.mobile
          this.readonly = true
        })
      },
      keepDeptChange (id, item) {
        // console.log(2);
        // this.employees = []
        // this.dataForm.keepUserId = ''
        this.$http({
          url: this.$http.adornUrl('/certificate/employeeInfo/list'),
          method: 'get',
          params: this.$http.adornParams({
            'filterFlag': 0,
            'deptId': id,
            'page': 1,
            'limit': 1000,
            'status': 1
          })
        }).then(({data}) => {
          if (data.code === 0) {
            this.employees = data.page.list
            let employList = this.employees.filter(item=>item.id === this.dataForm.keepUserId)
            if(employList.length < 1){
              this.dataForm.keepUserId = ''
            }
/*            if (!this.dateForm.keepUserId && this.employees.length > 0) {
              this.dataForm.keepUserId = this.employees[0].id
            }*/
            // 默认保管部门
            if (!this.dataListForm) {
              // this.dataForm.keepUserId = data.page.list[0].id
            } else {
              // this.dataForm.keepUserId = this.dataListForm.keepUserId
            }
          }
        })
      },
      employeesChange (item) {
        // console.log(item);
        this.$http({
          url: this.$http.adornUrl('/certificate/employeeInfo/info/' + item),
          method: 'get'
        }).then(({data}) => {
          if (data.code === 0) {
            this.dataForm.keepDeptId = data.e.deptId
          }
        })
        this.dataForm.keepDeptId = item.deptId
      },
      initOrgTree () {
        this.$http({
          url: this.$http.adornUrl('/tenant/tenantDeptInfo/tree'),
          method: 'get',
          params: {}
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.treeData = [data.deptInfo]
            // 默认保管人
            this.dataForm.keepDeptId = this.treeData[0].children[0].id
          } else {
            this.treeData = []
          }
        })
      },
      dataFormSubmit () {
        this.dataListLoading = true
        this.$refs.dataForm.validate(valid => {
          if (!valid) {
            this.dataFormSubmitCenterDialogVisible = true
            this.dataListLoading = false
          } else {
            if (!this.isField && !this.editmodification) {
              console.log(23)
              let certiPic = '', constractPic = ''
              if (this.certiPicList.length > 0) {
                for (let i in this.certiPicList) {
                  certiPic += this.certiPicList[i].response.fileName + ','
                }
              }
              if (this.payPic.length > 0) {
                for (let i in this.payPic) {
                  constractPic += this.payPic[i].response.fileName + ','
                }
              }
              if (!constractPic) {
                constractPic = this.img[0].url
                var p = this.img[0].url.split('/')
                certiPic = p[p.length - 1]
              }
              if (this.checked) {
                this.dataForm.validityEndTime = ''
                this.dataForm.longTerm = 1
              }
              if (!this.checked) {
          // this.dataForm.validityEndTime = ''
                this.dataForm.longTerm = 0
              }
              this.$refs['dataForm'].validate((valid) => {
                if (valid) {
                  this.$http({
                    url: this.$http.adornUrl(`/certificate/certificateInfo/save`),
                    method: 'post',
                    data: this.$http.adornData({
                      'examAgencyFlag': this.dataForm.examAgencyFlag,
                      'examAgencyName': this.dataForm.examAgencyName,
                      'examAgencyFee': this.dataForm.examAgencyFee,
                      'payTime': this.dataForm.payTime,
                      'affiliationEmployee': this.dataForm.affiliationEmployee,
                      'employeeId': this.dataForm.employeeId,
                      'totalFee': this.dataForm.totalFee,
                      'longTerm': this.dataForm.longTerm,
                      'agencyFee': this.dataForm.agencyFee,
                      'certificateType': this.dataForm.certificateType,
                      'pIdType': this.dataForm.pIdType,
                      'confType': this.dataForm.pIdType,
                      'idType': this.dataForm.idType,
                      'academic': this.dataForm.academic,
                      'certificateNo': this.dataForm.certificateNo,
                      'releaseTime': this.$dateFormat(this.dataForm.releaseTime),
                      'validityEndTime': this.$dateFormat(this.dataForm.validityEndTime),
                      'keepDeptId': this.dataForm.keepDeptId,
                      'keepUserId': this.dataForm.keepUserId,
                      'remark': this.dataForm.remark,
                      'name': this.dataForm.name,
                      'constractPic': constractPic,
                      'onCompanyFlag': this.dataForm.onCompanyFlag,
                      'examTime': this.dataForm.examTime,
                      'examLocation': this.dataForm.examLocation,
                      'examGrade': this.dataForm.examGrade,
                      'examFee': this.dataForm.examFee,
                      'borrowContactRelationship': this.dataForm.borrowContactRelationship,
                      'borrowContact': this.dataForm.borrowContact,
                      'friendshipEmployeeId': this.dataForm.friendshipEmployeeId,
                      'agencyFlag': this.dataForm.agencyFlag,
                      'agencyName': this.dataForm.agencyName,
                      'affiliationExpend': this.dataForm.affiliationExpend,
                      'tax': this.dataForm.tax,
                      'payFlag': this.dataForm.payFlag,
                      'feeRemark': this.dataForm.feeRemark,
                      // 'remark': this.dataForm.remark,
                      'registerType': this.dataForm.registerType,
                      'profession': this.dataForm.profession,
                      'idCard': this.dataForm.idCard,
                      'orgName': this.dataForm.orgName,
                      'mobile': this.dataForm.mobile,
                      'contact': this.dataForm.contact,
                      'contactMobile': this.dataForm.contactMobile,
                      'borrowCandidatesSources': this.dataForm.borrowCandidatesSources,
                      'borrowOrgName': this.dataForm.borrowOrgName,
                      'borrowContactMobile': this.dataForm.borrowContactMobile,
                      'friendshipMobile': this.dataForm.friendshipMobile,
                      'borrowTime': this.$dateFormat(this.dataForm.borrowTime),
                      'borrowEndTime': this.$dateFormat(this.dataForm.borrowEndTime),
                      'certiPic': certiPic,
                      'companyEndTime': this.dataForm.companyEndTime
                    })
                  }).then(({data}) => {
                    if (data && data.code === 0) {
                      this.$message({
                        message: '添加成功',
                        type: 'success',
                        duration: 1500,
                        onClose: () => {
                          this.dataListLoading = false
                          this.$refs.dataForm.resetFields()
                          this.$emit('routerBack')
                        }
                      })
                    } else {
                      this.$message.error(data.msg)
                      this.dataListLoading = false
                    }
                  })
                }
              })
            }
            if (this.isField) {
              let certiPic = '', constractPic = ''
              if (this.certiPicList.length > 0) {
                for (let i in this.certiPicList) {
                  certiPic += this.certiPicList[i].response.fileName + ','
                }
              }
              if (this.payPic.length > 0) {
                for (let i in this.payPic) {
                  constractPic += this.payPic[i].response.fileName + ','
                }
              }
              if (this.checked) {
                this.dataForm.validityEndTime = ''
                this.dataForm.longTerm = 1
              }
              this.$refs['dataForm'].validate((valid) => {
                if (valid) {
                  this.$http({
                    url: this.$http.adornUrl(`/certificate/certificateInfo/save`),
                    method: 'post',
                    data: this.$http.adornData({
                      'examAgencyFlag': this.dataForm.examAgencyFlag,
                      'examAgencyName': this.dataForm.examAgencyName,
                      'examAgencyFee': this.dataForm.examAgencyFee,
                      'payTime': this.dataForm.payTime,
                      'totalFee': this.dataForm.totalFee,
                      'agencyFee': this.dataForm.agencyFee,
                      'affiliationEmployee': this.dataForm.affiliationEmployee,
                      'employeeId': this.dataForm.employeeId,
                      'certificateType': this.dataForm.certificateType,
                      'pIdType': this.dataForm.pIdType,
                      'confType': this.dataForm.pIdType,
                      'longTerm': this.dataForm.longTerm,
                      'idType': this.dataForm.idType,
                      'academic': this.dataForm.academic,
                      'companyEndTime': this.dataForm.companyEndTime,
                      'certificateNo': this.dataForm.certificateNo,
                      'releaseTime': this.$dateFormat(this.dataForm.releaseTime),
                      'validityEndTime': this.$dateFormat(this.dataForm.validityEndTime),
                      'keepDeptId': this.dataForm.keepDeptId,
                      'keepUserId': this.dataForm.keepUserId,
                      'remark': this.dataForm.remark,
                      'name': this.dataForm.name,
                      'constractPic': constractPic,
                      'onCompanyFlag': this.dataForm.onCompanyFlag,
                      'examTime': this.dataForm.examTime,
                      'examLocation': this.dataForm.examLocation,
                      'examGrade': this.dataForm.examGrade,
                      'examFee': this.dataForm.examFee,
                      'borrowContactRelationship': this.dataForm.borrowContactRelationship,
                      'borrowContact': this.dataForm.borrowContact,
                      'friendshipEmployeeId': this.dataForm.friendshipEmployeeId,
                      'agencyFlag': this.dataForm.agencyFlag,
                      'agencyName': this.dataForm.agencyName,
                      'affiliationExpend': this.dataForm.affiliationExpend,
                      'tax': this.dataForm.tax,
                      'payFlag': this.dataForm.payFlag,
                      'feeRemark': this.dataForm.feeRemark,
                     // 'remark': this.dataForm.remark,
                      'registerType': this.dataForm.registerType,
                      'profession': this.dataForm.profession,
                      'idCard': this.dataForm.idCard,
                      'orgName': this.dataForm.orgName,
                      'mobile': this.dataForm.mobile,
                      'contact': this.dataForm.contact,
                      'contactMobile': this.dataForm.contactMobile,
                      'borrowCandidatesSources': this.dataForm.borrowCandidatesSources,
                      'borrowOrgName': this.dataForm.borrowOrgName,
                      'borrowContactMobile': this.dataForm.borrowContactMobile,
                      'friendshipMobile': this.dataForm.friendshipMobile,
                      'borrowTime': this.$dateFormat(this.dataForm.borrowTime),
                      'borrowEndTime': this.$dateFormat(this.dataForm.borrowEndTime),
                      'certiPic': certiPic
                    })
                  }).then(({data}) => {
                    if (data && data.code === 0) {
                      this.$message({
                        message: '添加成功',
                        type: 'success',
                        duration: 1500,
                        onClose: () => {
                  // this.$parent.initJobs()
                          this.dataForm.certificateNo = ''
                          this.dataForm.examTime = ''
                          this.dataForm.examLocation = ''
                          this.dataForm.examGrade = ''
                          this.dataForm.examFee = ''
                          this.dataForm.releaseTime = ''
                          this.dataForm.validityEndTime = ''
                          this.dataForm.borrowTime = ''
                          this.dataForm.borrowEndTime = ''
                          this.dataForm.borrowOrgName = ''
                          this.dataForm.borrowContact = ''
                          this.dataForm.friendshipEmployeeId = ''
                          this.dataForm.borrowContactMobile = ''
                          this.dataForm.friendshipMobile = ''
                          this.dataForm.affiliationExpend = ''
                          this.dataForm.feeRemark = ''
                          this.dataForm.remark = ''
                          this.showList = false
                          this.checked = false
                          this.dataForm.agencyFlag = ''
                          this.dataForm.agencyFee = ''
                          this.dataForm.agencyName = ''
                          this.dataForm.otherFee = ''
                          this.dataForm.payFlag = ''
                          this.dataForm.tax = ''
                          this.dataForm.payTime = ''
                          this.dataForm.borrowContactRelationship = ''
                          this.dataForm.companyEndTime = ''
                          this.dataForm.examAgencyFlag = ''
                          this.dataForm.examAgencyName = ''
                          this.dataForm.examAgencyFee = ''
                          this.dataListLoading = false
                        }
                      })
                    } else {
                      this.$message.error(data.msg)
                      this.dataListLoading = false
                    }
                  })
                }
              })
            }
            if (this.editmodification) {
        // console.log(159);
              let certiPic = '', constractPic = ''
              if (this.certiPicList.length > 0) {
                for (let i in this.certiPicList) {
                  certiPic += this.certiPicList[i].response.fileName + ','
                }
              }
              if (this.payPic.length > 0) {
                for (let i in this.payPic) {
                  constractPic += this.payPic[i].response.fileName + ','
                }
              }
              if (this.checked) {
                this.dataForm.validityEndTime = ''
                this.dataForm.longTerm = 1
              }
              this.$refs['dataForm'].validate((valid) => {
                if (valid) {
                  this.$http({
                    url: this.$http.adornUrl(`/certificate/certificateInfo/update`),
                    method: 'post',
                    data: this.$http.adornData({
                      'examAgencyFlag': this.dataForm.examAgencyFlag,
                      'examAgencyName': this.dataForm.examAgencyName,
                      'examAgencyFee': this.dataForm.examAgencyFee,
                      'id': this.dataListForm.id,
                      'payTime': this.dataForm.payTime,
                      'employeeId': this.dataForm.employeeId,
                      'otherFee': this.dataForm.otherFee,
                      'agencyFee': this.dataForm.agencyFee,
                      'affiliationEmployee': this.dataForm.affiliationEmployee,
                      'certificateType': this.dataForm.certificateType,
                      'pIdType': this.dataForm.pIdType,
                      'confType': this.dataForm.pIdType,
                      'idType': this.dataForm.idType,
                      'academic': this.dataForm.academic,
                      'companyEndTime': this.dataForm.companyEndTime,
                      'certificateNo': this.dataForm.certificateNo,
                      'releaseTime': this.$dateFormat(this.dataForm.releaseTime),
                      'validityEndTime': this.$dateFormat(this.dataForm.validityEndTime),
                      'keepDeptId': this.dataForm.keepDeptId,
                      'keepUserId': this.dataForm.keepUserId,
                      'remark': this.dataForm.remark,
                      'name': this.dataForm.name,
                      'constractPic': constractPic,
                      'onCompanyFlag': this.dataForm.onCompanyFlag,
                      'examTime': this.dataForm.examTime,
                      'examLocation': this.dataForm.examLocation,
                      'examGrade': this.dataForm.examGrade,
                      'examFee': this.dataForm.examFee,
                      'borrowContactRelationship': this.dataForm.borrowContactRelationship,
                      'borrowContact': this.dataForm.borrowContact,
                      'friendshipEmployeeId': this.dataForm.friendshipEmployeeId,
                      'agencyFlag': this.dataForm.agencyFlag,
                      'agencyName': this.dataForm.agencyName,
                      'affiliationExpend': this.dataForm.affiliationExpend,
                      'tax': this.dataForm.tax,
                      'payFlag': this.dataForm.payFlag,
                      'feeRemark': this.dataForm.feeRemark,
                      // 'remark': this.dataForm.remark,
                      'registerType': this.dataForm.registerType,
                      'profession': this.dataForm.profession,
                      'idCard': this.dataForm.idCard,
                      'orgName': this.dataForm.orgName,
                      'mobile': this.dataForm.mobile,
                      'contact': this.dataForm.contact,
                      'contactMobile': this.dataForm.contactMobile,
                      'borrowCandidatesSources': this.dataForm.borrowCandidatesSources,
                      'borrowOrgName': this.dataForm.borrowOrgName,
                      'borrowContactMobile': this.dataForm.borrowContactMobile,
                      'friendshipMobile': this.dataForm.friendshipMobile,
                      'borrowTime': this.$dateFormat(this.dataForm.borrowTime),
                      'borrowEndTime': this.$dateFormat(this.dataForm.borrowEndTime),
                      'certiPic': certiPic
                    })
                  }).then(({data}) => {
                    if (data && data.code === 0) {
                      this.$message({
                        message: '修改成功',
                        type: 'success',
                        duration: 1500,
                        onClose: () => {
                          this.dataListLoading = false
                        }
                      })
                    } else {
                      this.$message.error(data.msg)
                      this.dataListLoading = false
                    }
                  })
                }
              })
            }
          }
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
/deep/.upload-ss{
.div-ssup{
  .el-upload-list__item-actions{
    .delete-sse{
      z-index:10
    }
  }
}
}
.cuowu{
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
  color: red;
  font-weight: 700;
}
.button-see{
  font-size: 14px;
}
.col-buttons{
  float: right;
}
.div-mau{
  background-color: #ffffff;
}
// .itemCheck{
//   display: flex;
//   // justify-content: center;
//   align-items: center;
// }
    .demo-drawer {
        &__content {
            display: flex;
            flex-direction: column;
            height: 100%;
            form {
                flex: 1;
            }
        }
        &__footer {
            display: flex;
            button {
                flex: 1;
            }
        }
        &__header {
            text-align:right;
            margin-bottom:20px;
            width:100%;
        }
    }
    // 返回按钮
    .center-s{
      overflow: hidden;
      height: 38px;
      line-height: 38px;
      margin-bottom: 3px;
      h3{
        margin-left:30px;
        float: left;
      }
      h5{
        float: left;
        font-weight: 400;
        margin-left: 30px;
        color: orangered;
      }
      .clickBack{
      float: right;
      margin-right: 20px;
      }
    }
    .el-drawer__body {
        padding: 20px;
    }

    .el-upload-dragger{
      width: 100%;
    }
    .el-input__inner{
      height: 36px;
    }
    .clearfix:after{/*伪元素是行内元素 正常浏览器清除浮动方法*/
        content: "";
        display: block;
        height: 0;
        clear:both;
        visibility: hidden;
    }
   .clearfix{
       *zoom: 1;/*ie6清除浮动的方式 *号只有IE6-IE7执行，其他浏览器不执行*/
   }
</style>
